import {PropertyObject} from "./Property.Object.js";
import {PropertyMaterial} from "./Property.Material.js";
import {PropertyGeometry} from "./Property.Geometry.js";

function Property(editor) {

    var signals = editor.signals;

    var objectPanel = new PropertyObject(editor);
    var materialPanel = new PropertyMaterial(editor);
    var geometryPanel = new PropertyGeometry(editor);
    var config = {
        name: 'propertyPanel',
        active: 'object',
        style: 'background-color:#444; color:#888;',
        panels: [
            {
                type: 'main', html: 'main',
                style: {borderTop: '0', paddingTop: '20px'},
                tabs: {
                    active: 'object',
                    tabs: [
                        {id: 'object', text: 'object'},
                        {id: 'geometry', text: 'geometry'},
                        {id: 'material', text: 'material'},
                        {id: 'script', text: 'script'},
                    ],
                    onClick(event) {
                        console.log(event.target);
                        objectPanel.dom.style.display = 'none';
                        materialPanel.setDisplay('none');
                        switch (event.target){
                            case 'object':
                                w2ui.propertyPanel.html('main', objectPanel.dom);
                                objectPanel.setDisplay('');
                                break;
                            case 'material':
                                w2ui.propertyPanel.html('main', materialPanel.dom);
                                materialPanel.setDisplay('');
                                break;
                            case 'geometry':
                                w2ui.propertyPanel.html('main', geometryPanel.dom);
                                geometryPanel.setDisplay('');
                                break;
                        }
                        //this.owner.html('main', objectPanel);
                    }
                }
            }
        ]
    }


    $('#property').w2layout(config);
    w2ui.propertyPanel.html('main', objectPanel.dom);
    objectPanel.dom.style.display = 'none';
    editor.select(null);

    signals.editorCleared.add(()=>{
        w2ui.propertyPanel.html('main', objectPanel.dom);
        objectPanel.dom.style.display = 'none';
        editor.select(null);
    });
}

export {Property};
